package org.hawk.gwt.ppc.loader;

import java.net.URL;
import java.util.List;

import org.hawk.gwt.ppc.utils.PreprocessorException;

/**
 * This interface represents scanner for the sources in the 
 * specific classpath root.
 * @author alex.bereznevatiy@gmail.com
 *
 */
public interface SourcesLoader {
	
	/**
	 * Resolves all java sources from the classpath root
	 * assigned. Returns list of compilation unit names that sources 
	 * are available. 
	 * @param packageName
	 * @return list of class names and never <code>null</code>
	 */
	List<String> getCompilationUnits(String packageName);
	
	/**
	 * @param packageName
	 * @return list of names of all subpackages 
	 * for package specified.
	 */
	List<String> getSubpackages(String packageName);
	
	/**
	 * @param name
	 * @return {@link URL} of resource with the name specified.
	 */
	URL getResource(String name);
	
	/**
	 * @param name of the compilation unit to load source. 
	 * @return {@link URL} of compilation unit source with name specified.
	 */
	URL getCompilationUnit(String name);

	/**
	 * @return URL presentation of this source loader 
	 * 
	 * @throws PreprocessorException in case of troubles or if this source loader cannot be represented as single URL.
	 * 
	 */
	URL toUrl() throws PreprocessorException;

	/**
	 * @param resourceName - java name for resource to check
	 * @return <code>true</code> if resource (either compilation unit or package) with name specified exists
	 */
	boolean isExists(String resourceName);
}
